package com.smyh.bean.Enum;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;

/**
 * 遥测点位类型
 */
public enum PointMockType {
	A_AF(1,"A相电流"),B_AF(2,"B相电流"),C_AF(3,"C相电流"),O_AF(4,"0序电流"),
	A_E_FIELD(5,"A相电场"),B_E_FIELD(6,"B相电场"),C_E_FIELD(7,"C相电场"),O_E_FIELD(8,"0序电场"),
	A_BVF(9,"A相电池电压"),B_BVF(10,"B相电池电压"),C_BVF(11,"C相电池电压"),
	A_TF(12,"A相温度"),B_TF(13,"B相温度"),C_TF(14,"C相温度"),
	A_CEV(15,"A相指示器电容电压"),B_CEV(16,"B相指示器电容电压"),C_CEV(17,"C相指示器电容电压"),
	A_FE(18,"A相故障电流"),B_FE(19,"B相故障电流"),C_FE(20,"C相故障电流"),O_FE(21,"0序故障电流"),
	A_BY_1(22,"A相备用-1"),B_BY_1(23,"B相备用-1"),C_BY_1(24,"C相备用-1"),
	A_BY_2(25,"A相备用-2"),B_BY_2(26,"B相备用-2"),C_BY_2(27,"C相备用-2"),
	A(100,"太阳能充电电压"),B(101,"电池电压"),C(102,"信号强度"),
	D(103,"备用1"),E(104,"备用2"),F(105,"备用3"),G(106,"备用4");
	
	

	private String name;
	private int index;
	/**
	 * 构造方法
	 * @param index
	 * @param desc
	 */
	PointMockType(int index,String desc){
		this.setIndex(index);
		this.setName(desc);
	}
	public static List<String> getFiltNames(){
		List<String> list = new ArrayList<String>();
		for (PointMockType pointMockType : PointMockType.values()) {
			if(pointMockType.getName().contains("A相")){
				if(!pointMockType.getName().contains("备用"))
					list.add(pointMockType.getName().substring(2));
			}
		}
		return list;
	}
	public static List<Integer> containsNameCount(String name){
		 List<Integer> list = new ArrayList<Integer>();
		for (PointMockType pointMockType : PointMockType.values()) {
			if(pointMockType.getName().contains(name)&&pointMockType.getName().length()-name.length()==2){
				list.add(pointMockType.getIndex());
			}
		}
		Collections.sort(list);
		return list;
		
	}
	public static void main(String[] args) {
		System.out.println(containsNameCount("故障电流"));
	}
	/**
	 * 普通方法
	 */
    public static String getName(Integer index) {
    	if( index == null || index==0 ){
    		return "";
    	}
        for (PointMockType pointMockType : PointMockType.values()) {  
            if (pointMockType.getIndex() == index) {  
                return pointMockType.name;  
            }  
        }  
        return " ";  
    }
    public static Integer getIndex(String name) {
		if("".equals(name)||name == null){
			return null;
		}
    	for (PointMockType pointMockType : PointMockType.values()) {  
    		if (pointMockType.getName().equals(name)) {  
    			return pointMockType.index;  
    		}  
    	}  
    	return null;  
    }
    
    private static Vector vectors = null;
    /**
     * 返回所有的index
     * @return
     */
    public static Vector<Object> getIndexs(){
    	if(vectors==null){
    		vectors = new Vector<Object>();
    		vectors.add("");
    		for (PointMockType pointMockType : PointMockType.values()) {
    			vectors.add(pointMockType.index);
    		}
    	}
    	return vectors;
    }
    public static Vector<Object> getNames(){
    	if(vectors==null){
    		vectors = new Vector<Object>();
    		vectors.add("");
    		for (PointMockType pointMockType : PointMockType.values()) {
    			vectors.add(pointMockType.name);
    		}
    	}
    	return vectors;
    }
	public void setIndex(int index) {
		this.index = index;
	}
	public int getIndex() {
		return index;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
}
